Skip to content

Number consensus lock holds in trace events - #8779

Closed
cjen1-msft wants to merge 1 commit into
mainfrom
cjen1-msft-trace-consensus-lock-holds
Closed

cjen1-msft wants to merge 1 commit into
mainfrom
cjen1-msft-trace-consensus-lock-holds

Conversation

@cjen1-msft

Copy link
Copy Markdown
Contributor

Consensus trace consumers, such as the Lean replayer, rely on every consensus event being emitted while the node holds its consensus lock: that is what makes a node's event order a serial order of its critical sections, whichever threads ran them. Nothing checks this today, so a change that traces outside the lock, or releases it part-way through a section, would silently weaken trace validation.

This PR makes the assumption visible in the trace. Each consensus event records lock_hold, the number of the lock hold it was emitted in, or 0 if it was emitted outside the lock, so a consumer can check that each group of events is exactly one hold instead of assuming it. Checking the field in the replayer is left to a follow-up, once #8735 has landed.

Safety and compatibility

aft::State::lock becomes a ccf::tracing::TracedMutex, which adds a few thread-local accesses and a counter increment per acquisition, with or without tracing enabled. Locking behaviour is otherwise unchanged.

Events under the ccf.cft Fluentd tag gain a lock_hold field in msg; the record envelope is unchanged and collectors need no configuration change.

Trace events declared with DECLARE_TRACE_EVENT record lock_hold, the hold
of a TracedMutex they are emitted in, and the consensus state lock is now
one. A trace consumer can then check that the lock serializes each node's
events instead of assuming it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant